// TDlambda.h: interface for the TDlambda class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_TDLAMBDA_H__B1300ADE_7C82_4DE6_902C_FDF5E2055F93__INCLUDED_)
#define AFX_TDLAMBDA_H__B1300ADE_7C82_4DE6_902C_FDF5E2055F93__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


/**
 * \class TDlambda
 * \author Peter Lacko
 * \brief Neural network with TD(lamda) learning 
 */

class TDlambda  
{
public:
	TDlambda(int inCountInputLayer, int inCountHiddenLayer, double inAlpha, double inLambda);
	~TDlambda();

	///Initialization
	int Initialize();

	///
	int SaveNetToDisk(char* fileName);
	int LoadNetFromDisk(char* fileName);

	///
	double GetNetResponse(double *input, double *y);

	int GradientConstruction(double **P_seq, double z_reward, int length);
//	int UpdateWeights();

private:
	double Random();
	double ActivationFunction(double net);
	int LocalGradientConstruction(double *x, double *y, double z, double **gradientHiddenLayer, double *gradientOutputLayer);

private:
	double **weightsHiddenLayer;
	double *weightsOutputLayer;

	double **deltaWeightsHiddenLayer;
	double *deltaWeightsOutputLayer;

	int countInputLayer;
	int countHiddenLayer;

	double lambda;		///cTD parameter
	double alpha;		///learning speed
};

#endif // !defined(AFX_TDLAMBDA_H__B1300ADE_7C82_4DE6_902C_FDF5E2055F93__INCLUDED_)
